package com.giraffe.device.repository;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.giraffe.common.core.enums.DelFlagStatusEnum;
import com.giraffe.common.core.enums.EnableStatusEnum;
import com.giraffe.device.domain.Device;
import com.giraffe.device.mapper.DeviceMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 产品(Product)表数据库访问层
 *
 * @author makejava
 * @since 2023-02-14 10:39:59
 */
@Component
public class DeviceRepository extends ServiceImpl<DeviceMapper, Device> {

  /**
   * 根据id集合查询数据
   *
   * @param idList id集合
   * @return
   */
  public List<Device> findByIds(List<String> idList) {
    return this.lambdaQuery().eq(Device::getDelFlag, DelFlagStatusEnum.NORMAL.getCode())
        .in(Device::getId, idList)
        .list();
  }
  
  /**
   * 根据id集合和启禁用状态查询数据
   *
   * @param statusEnum 启禁用状态
   * @param idList     id集合
   * @return
   */
  public List<Device> findEnableStatusByIds(EnableStatusEnum statusEnum, List<String> idList) {
    return this.lambdaQuery().eq(Device::getDelFlag, DelFlagStatusEnum.NORMAL.getCode())
        .eq(Device::getEnableStatus, statusEnum.getCode())
        .in(Device::getId, idList)
        .list();
  }
}

